

from base import Base
from selenium.webdriver.common.by import By
from time import sleep

# 定义页面类，继承基类
class SouSuoPage(Base):

    sousuokuang = (By.XPATH, '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.TextSwitcher/android.widget.TextView')

    sousuoanniu = (By.XPATH, '//android.widget.TextView[@text="搜索"]')

    dy = (By.ID, 'com.xiachufang:id/search_suggest_right_text_view')

    def sousuoyewu(self):
        # 点击搜索框
        self.find_ele(self.sousuokuang).click()
        sleep(2)
        # 点击搜索按钮
        self.find_ele(self.sousuoanniu).click()
        sleep(3)

    shurukuang = 'new UiSelector().text("搜索菜谱")'
    dy2 = (By.ID, 'com.xiachufang:id/tv_content')
    dy3 = (By.XPATH, '//android.widget.TextView[@text="综合"]')
    dy4 = (By.XPATH, '//android.widget.TextView[@resource-id="com.xiachufang:id/tv_content"]')

    def sousuoddtyewu(self, neirong):
        # 点击搜索框
        self.find_ele(self.sousuokuang).click()
        sleep(2)
        # 输入搜索内容
        self.find_ele(self.shurukuang).send_keys(neirong)
        # 点击搜索按钮
        self.find_ele(self.sousuoanniu).click()
        sleep(3)